<!DOCTYPE html>
<html>
    <head>
	  <title>升降机监控</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="zh-CN" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
      <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
      <meta name="format-detection" content="telephone=no"/>
			<link rel="stylesheet" href="css/bootstrap.min.css">
			<link rel="stylesheet" type="text/css" href="css/index.css"/>
			<link rel="stylesheet" href="css/swiper.min.css">
			<script src="js/swiper.min.js"></script>
			<style>
				.title_top{text-align: center;}
				.rq{padding: 0;}
				.rq a{color: #FFF;}
				.projectname{font-size:17px;font-weight:bolder;margin-top:20px;}
			</style>
    </head>
	<body class="body_2">
		<div class="col-xs-12 title_top">
			<div class="col-xs-3 rq back">
				<a href="javascript:history.back(-1)">
					<div style="float: left;"><img src="images/icon_left.png"/></div>
					<div style="float: left;margin-top: 2px;">返回</div>
				</a>
			</div>
			<div class="col-xs-6">升降机监控</div>
			<div class="col-xs-3" style="padding-right: 0;">
				
			</div>
		</div>
		<div class="col-xs-12 monitor" style="margin-top: 60px;">
			<div class="col-xs-12 monitor_title projectname">项目名称</div>
			<div class="col-xs-12 monitor_top_1 builders">施工单位：施工单位名称</div>
			<div class="col-xs-12 monitor_top_1 address">项目地址：项目地址</div>
			
			<div class="col-xs-12 monitor_monitor lists">
				
			</div>
		</div>
	</body>
	<script>
		var swiper = new Swiper('.swiper-container', {
			slidesPerView: 1.1,
			spaceBetween: 5,
		});
	</script>
</html>
<script src="js/mui.min.js"></script>
<script src="js/project.config.js"></script>
<script src="js/jquery.min.js"></script>
<script>
    mui.plusReady(function () {
        var token = get_token();
		var params = get_ws();
		if(!params.projectID){
			_mui_dialog._toast('请勿非法访问');
			return false;
		}
		//时间戳
		var today_start_time = today_end_time = week_start_time = week_end_time = '';
		mui.ajax(project_cofnig.service_time, {
			async: false,
			dataType: 'json',
			data: {},
			success: function (ref) {
				today_start_time = ref.start_today;
				today_end_time = ref.end_today;
			}
		});
		mui.ajax(project_cofnig.service_past_time, {
			async: false,
			dataType: 'json',
			data: {type:7},
			success: function (ref) {
				week_start_time = ref.start_time;
				week_end_time = ref.end_time;
			}
		});
		//项目详情
		var data = {};
        data.api = 'project-details-info';
        data.token = token;
        data.projectID = params.projectID;
		mui.ajax(project_cofnig.service_url, {
			async: true,
			dataType: 'json',
			data: data,
			success: function (ref) {
				if (ref.code == 0) {
					$.each(ref.data.project,function(i,v){
						$(".projectname").html(v.projectname);
						$(".builders").html('施工单位：'+v.builders);
						$(".address").html('项目地址：'+v.address);
					});
				} else {
					_mui_dialog._toast(ref.message);
				}
				return false;
			}
		});
		//升降机详情
		data.api = 'elevator-get-device';
        mui.ajax(project_cofnig.service_url, {
            async: true,
            dataType: 'json',
            data: data,
            success: function (ref) {
                if (ref.code == 0) {
                    var _html = '';
						_html += '<div class="swiper-container">';
						_html += '<div class="swiper-wrapper">';
                    	mui(ref.data.elevators).each(function (i, v) {
							//升降机统计数据
							var data = {};
							data.token = token;
							data.recordNum = v.recordNum;
							data.api = 'elevator-get-work-cycle-statisticsinfo';
							data.startTime = week_start_time;
							data.endTime = week_end_time;
							data.justCount = 1;
							var totalWorkCount = alarmWorkCount = todayWorkCount = todayAlarmCount = 0;
							mui.ajax(project_cofnig.service_url, {
									async: false,
									dataType: 'json',
									data: data,
									success: function (ref) {
										totalWorkCount = ref.data.totalWorkCount;
										alarmWorkCount = ref.data.alarmWorkCount;
										todayWorkCount = ref.data.todayWorkCount;
										todayAlarmCount = ref.data.todayAlarmCount;
									}
							});
							if(v.left != undefined){
								var statusDesLeftColor = '';
								switch(v.left.statusDesc){
									case '报警':
										statusDesLeftColor = '#DC143C';
										break;
									case '预警':
										statusDesLeftColor = '#FF8C00';
										break;
									case '离线':
										statusDesLeftColor = '#808080';
										break;
									case '违章':
										statusDesLeftColor = '#FFFF00';
										break;
									default:
										statusDesLeftColor = '#90EE90';
										break;
								}
								_html += '<div class="swiper-slide" data-recordnum="'+v.recordNum+'" >';
								_html += '<div class="col-xs-12 monitor_monitor_top_1">';
								_html += '<div class="col-xs-3 monitor_monitor_top_left"><img src="images/elevator_icon.png" /></div>';
								_html += '<div class="col-xs-9 monitor_monitor_top_right">';
								_html += '<div class="monitor_monitor_p_1">升降机备案：<span>'+v.recordNum+'</span>';
								_html += '<div class="monitor_monitor_p_3" style="color:'+statusDesLeftColor+'">'+v.left.statusDesc+'</div></div>';
								_html += '<p class="monitor_monitor_p_2">升降机驾驶：'+v.left.driverName+'</p></div></div>';
								_html += '<div class="col-xs-12 monitor_monitor_top_2">'; 
								_html += '<p class="monitor_monitor_p_5">左吊笼</p>';
								_html += '<p class="monitor_monitor_p_4">黑匣子ID：<span>'+v.left.blackBoxID+'</span></p>';
								_html += '<p class="monitor_monitor_p_4">载重：<span>'+v.left.weight+'吨</span></p>';
								_html += '<p class="monitor_monitor_p_4">高度：<span>'+v.left.height+'米</span></p>';
								_html += '<p class="monitor_monitor_p_4">速度：<span>'+v.left.speed+'米/秒</span></p></div>';
								_html += '<div class="col-xs-12 monitor_monitor_top_4">';
								_html += '<div class="col-xs-6 monitor_monitor_top_4_left">';
								_html += '<div class="col-xs-12 a_a total"  data-status="0" data-type="today" ><a href="#">今日吊装：'+todayWorkCount+'次</a></div>';
								_html += '<div class="col-xs-12 a_b total" data-status="0" data-type="week" ><a href="#">本周吊装：'+totalWorkCount+'次</a></div></div>';
								_html += '<div class="col-xs-6 monitor_monitor_top_4_right">';
								_html += '<div class="col-xs-12 a_a total" data-status="F" data-type="today" ><a href="#">今日违章：'+todayAlarmCount+'次</a></div>';
								_html += '<div class="col-xs-12 a_b total" data-status="F" data-type="week" ><a href="#">本周违章：'+alarmWorkCount+'次</a></div></div></div></div>';
						}
						if(v.right != undefined){
								var statusDesRightColor = '';
								switch(v.right.statusDesc){
									case '报警':
										statusDesRightColor = '#DC143C';
										break;
									case '预警':
										statusDesRightColor = '#FF8C00';
										break;
									case '离线':
										statusDesRightColor = '#808080';
										break;
									case '违章':
										statusDesRightColor = '#FFFF00';
										break;
									default:
										statusDesRightColor = '#90EE90';
										break;
								}
								_html += '<div class="swiper-slide"  data-recordnum="'+v.recordNum+'" >';
								_html += '<div class="col-xs-12 monitor_monitor_top_1">';
								_html += '<div class="col-xs-3 monitor_monitor_top_left"><img src="images/elevator_icon.png" /></div>';
								_html += '<div class="col-xs-9 monitor_monitor_top_right">';
								_html += '<div class="monitor_monitor_p_1">升降机备案：<span>'+v.recordNum+'</span>';
								_html += '<div class="monitor_monitor_p_3" style="color:'+statusDesRightColor+'">'+v.right.statusDesc+'</div></div>';
								_html += '<p class="monitor_monitor_p_2">升降机驾驶：'+v.right.driverName+'</p></div></div>';
								_html += '<div class="col-xs-12 monitor_monitor_top_2">'; 
								_html += '<p class="monitor_monitor_p_5">右吊笼</p>';
								_html += '<p class="monitor_monitor_p_4">黑匣子ID：<span>'+v.right.blackBoxID+'</span></p>';
								_html += '<p class="monitor_monitor_p_4">载重：<span>'+v.right.weight+'吨</span></p>';
								_html += '<p class="monitor_monitor_p_4">高度：<span>'+v.right.height+'米</span></p>';
								_html += '<p class="monitor_monitor_p_4">速度：<span>'+v.right.speed+'米/秒</span></p></div>';
								_html += '<div class="col-xs-12 monitor_monitor_top_4">';
								_html += '<div class="col-xs-6 monitor_monitor_top_4_left">';
								_html += '<div class="col-xs-12 a_a total" data-status="0" data-type="today" ><a href="#">今日吊装：'+todayWorkCount+'次</a></div>';
								_html += '<div class="col-xs-12 a_b total" data-status="0" data-type="week" ><a href="#">本周吊装：'+totalWorkCount+'次</a></div></div>';
								_html += '<div class="col-xs-6 monitor_monitor_top_4_right">';
								_html += '<div class="col-xs-12 a_a total" data-status="F" data-type="today" ><a href="#">今日违章：'+todayAlarmCount+'次</a></div>';
								_html += '<div class="col-xs-12 a_b total" data-status="F" data-type="week" ><a href="#">本周违章：'+alarmWorkCount+'次</a></div></div></div></div>';
								}
});
								_html += ' </div>';
								_html += '</div>';
								$(".lists").append(_html);
								var swiper = new Swiper('.swiper-container', {slidesPerView: 1.1,spaceBetween: 5,});
				                } else {
									_mui_dialog._toast(ref.message);
				                }
				                return false;
				            }
        });
		//统计详情
		mui("body").on('tap','.total',function(){
			var _this = $(this);
			var recordNum = _this.parents(".swiper-slide").data('recordnum');
			var status = _this.data('status');
			var type = _this.data('type');
			var start_time = (type == 'today' ? today_start_time : week_start_time);
			var end_time = (type == 'today' ? today_end_time : week_end_time);
			redirect('el_log.html',{
				recordNum:recordNum,
				status:status,
				startTime:start_time,
				endTime:end_time,
			});
		});	
		mui(".title_top").on("tap",".back",function(){
			mui.back();
		});
    });
</script>
		 